package com.example.myapplication.TouchDemo;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;

public class TestView1 extends View {
    public TestView1(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawColor(Color.BLUE);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Toast.makeText(this.getContext(),"onTouchEvent..."+event.getAction(),Toast.LENGTH_SHORT).show();
        return  true;
        ///onTouchEvent和onTouch优先级高于onLongClick和onClick.
        ///当有onTouchEvent，却没有onTouch，只执行当有onTouchEvent，后续的onLongClick和onClick无论true,还是false都不会执行，
    }
}
